layui.define(function(e) {
	layui.use(["admin", "carousel"], function() {
		var e = layui.$,
			a = (layui.admin, layui.carousel),
			t = layui.element,
			i = layui.device();
		e(".layadmin-carousel").each(function() {
			var t = e(this);
			a.render({
				elem: this,
				width: "100%",
				arrow: "none",
				interval: t.data("interval"),
				autoplay: t.data("autoplay") === !0,
				trigger: i.ios || i.android ? "click" : "hover",
				anim: t.data("anim")
			})
		}), t.render("progress")
	}), layui.use(["carousel", "echarts"], function() {
		var e = layui.$,
			a = (layui.carousel, layui.echarts);
		initCharts = function(option, id, func) {
			var t = [],
				n = e("#" + id).children("div"),
				l = function(e) {
					t[e] = a.init(n[e], layui.echartsTheme), t[e].setOption(option[e]), window.onresize = t[e].resize;
					t[e].on('click', function(params) {
						func(params)
					});
				};
			if(n[0]) {
				l(0);
			}
		}

		// 科室
		var o_ks = [{
/*			title: {
				text: '门诊日报明细',
				subtext: '3月1日',
				x: 'center'
			},*/
			tooltip: {
				trigger: 'item',
				formatter: "{a} <br/>{b} : {c} ({d}%)"
			},
			legend: {
				orient: 'vertical',
				x: 'left',
				data: ['中医科', '中医理疗', '中医正骨', '中医疼痛', '内科', '外科']
			},
			calculable: true,
			series: [{
				name: '访问来源',
				type: 'pie',
				radius: '55%',
				center: ['50%', 225],
				data: [{
						value: 335,
						name: '中医科'
					},
					{
						value: 310,
						name: '中医理疗'
					},
					{
						value: 234,
						name: '中医正骨'
					},
					{
						value: 135,
						name: '中医疼痛'
					},
					{
						value: 1548,
						name: '内科'
					},
					{
						value: 1548,
						name: '外科'
					}
				]
			}]
		}]
		initCharts(o_ks, "medical-detail-CZ-KS", clickPie);

		function clickPie1(params) {
			window.location.href = 'department_daily_sub_2.html';
		}
		initData_YS = function(options) {

			var o_ys = [{
				title: {
					text: options.title,
				},
				tooltip: {
					trigger: 'axis'
				},
				calculable: true,
				legend: {
					data: options.legendName
				},
				xAxis: [{
					type: 'category',
					data: options.xAxisData
				}],
				yAxis: [{
						type: 'value',
						name: '金额（元）',
						axisLabel: {
							formatter: '{value}'
						}
					},
					{
						type: 'value',
						name: '人数',
						axisLabel: {
							formatter: '{value}'
						}
					}
				],
				series: [

					{
						name: '金额',
						type: 'bar',
						data: options.seriesData.counts
					},
					{
						name: '人数',
						type: 'line',
						yAxisIndex: 1,
						data: options.seriesData.peoples
					}
				]
			}]

			initCharts(o_ys, "medical-detail-CZ", clickPie1);
		}

		function clickPie(params) {
			var name = params.data.name;
			var options = {};
			options.seriesData = {};
			options.title = name;
			options.legendName = ['金额', '人数'];
			options.xAxisData = ["郭素生", "勾舒强", "王淑云", "牛丽芬", "郭素生", "勾舒强", "王淑云"];
			options.seriesData.counts = [42.8, 53.9, 86.3, 65.9, 77.2, 38.5, 63.2];
			options.seriesData.peoples = [3, 5, 7, 6, 2, 4, 3];
			initData_YS(options)
		}

		initData = function() {
			var options = {};
			options.seriesData = {};
			options.title = "全部科室";
			options.legendName = ['金额', '人数'];
			options.xAxisData = ["郭素生", "勾舒强", "王淑云", "牛丽芬", "郭素生", "勾舒强", "王淑云", "牛丽芬", "王淑云", "牛丽芬", "郭素生", "勾舒强", "王淑云", "牛丽芬"];
			options.seriesData.counts = [42.8, 53.9, 86.3, 65.9, 77.2, 38.5, 63.2, 55.3, 86.3, 65.9, 77.2, 38.5, 63.2, 55.3];
			options.seriesData.peoples = [3, 5, 7, 6, 2, 4, 3, 3, 5, 7, 6, 2, 4, 3];
			initData_YS(options)
		}
		initData();

	}), e("department_daily_sub_1", {})
});